# import pymongo
# import random
# from bson.objectid import ObjectId
# from matplotlib import mlab
# from config.config import TEST_PORT,TEST_DB_HOST
# te = pymongo.MongoClient(TEST_DB_HOST,TEST_PORT)
# bs = te.bonded20231023
# wf = te.workflow_dev
# jw = te.backup20230920
# dates = ["10-16","10-17","10-18","10-19","10-20","10-21","10-22","10-23","10-24","10-25","10-26","10-27","10-28","10-29","10-30","10-31","11-01","11-02","11-03","11-04","11-05","11-06","11-07","11-08","11-09","11-10","11-11","11-12","11-13","11-14"]
# sizes = ["36","38.5","39","39.5","40","40.5","41","41.5","42","42.5","43","43.5","44","44.5","45","45.5"]
# s = 0
# li = []
# li1 = []
# xx = wf.dewu_history.find({"sku": '10061W','propertiesValues':"39.5","createTime":{"$regex":"10-24"}})
# for i in xx:
#     li.append(i)
#     s += i['price']
# yy = wf.suborders.find({"articleNumber": '10061W','size':"39.5","create_time":{"$regex":"10-24"}})
# for z in yy:
#     li1.append(z)
# print('得物销售均价:{}'.format(s/len(li)/100))
# print('得物销量：{}'.format(len(li)))
# print('wf销量：{}'.format(len(li1)))
# print('赢单率：{}'.format(len(li1)/len(li)))
# xx = bs.bids.find({"stockId":"Ay386MswuL"})
# for i in xx:
#     s+=i['bidSoldQty']
# print(s)

# wf.dewu_history.update_many({"sku":"10061W","createTime":{"$regex":"10-24"}},{"$set":{"createTime":"2023-10-23 10:58:47.000"}})
# wf.dewu_history.update_many({"sku":"10061W","createTime":{"$regex":"10-31"}},{"$set":{"createTime":"2023-10-23 10:58:47.000"}})
# wf.dewu_history.update_many({"sku":"10061W","createTime":{"$regex":"11-01"}},{"$set":{"createTime":"2023-10-24 10:58:47.000"}})
# wf.dewu_history.update_many({"sku":"10061W","createTime":{"$regex":"11-02"}},{"$set":{"createTime":"2023-10-25 10:58:47.000"}})
# wf.dewu_history.update_many({"sku":"10061W","createTime":{"$regex":"11-03"}},{"$set":{"createTime":"2023-10-26 10:58:47.000"}})
# wf.dewu_history.update_many({"sku":"10061W","createTime":{"$regex":"11-04"}},{"$set":{"createTime":"2023-10-27 10:58:47.000"}})
# wf.dewu_history.update_many({"sku":"10061W","createTime":{"$regex":"11-05"}},{"$set":{"createTime":"2023-10-28 10:58:47.000"}})
# wf.dewu_history.update_many({"sku":"10061W","createTime":{"$regex":"11-07"}},{"$set":{"createTime":"2023-10-29 10:58:47.000"}})
# wf.dewu_history.update_many({"sku":"10061W","createTime":{"$regex":"11-30"}},{"$set":{"createTime":"2023-11-07 10:58:47.000"}})

# xx = wf.suborders.find({"articleNumber":{"$nin":["BQ5448-116","CD7069-104"]}})
# for i in xx:
#     li.append(i['outerOrderNo'])
# wf.suborders.delete_many({"outerOrderNo":{"$in":li}})

# for z in sizes:
#     xx = wf.jointsuborders.find({'articleNumber': '10061W',"size":z})
#     for i in xx:
#         s+=i['orderAmount']
#     print(z,s)
#     s=0
# yy = bs.settlements.find({"stmtType":{"$ne":"return"}})
# s = 0
# li = []
# li1 = []
# dic = {}
# for i in dates:
#     yy = wf.suborders.find({"articleNumber":"10061M","create_time":{"$regex":i}})
#     for z in yy:
#         li.append(z['saleCost'][0]['value'])
#         li1.append(z['saleCost'][1]['value'])
#         s+=1
#     if s != 0:
#         print(i,s,sum(li)+sum(li1))
#     s = 0
#     li,li1 = [],[]
# for i in yy:
#     s+= i['amountCny']
# print(s)


# li = []
# li1 = []
# for i in xx:
#     li.append(i['saleCost'][0]['value'])
#     li1.append(i['saleCost'][1]['value'])
# print(sum(li))
# print(sum(li1))
# li = []
# dic = {}
# for i in yy:
#     li.append(i['sku_price'])
# for z in li:
#     if z not in dic:
#         dic[z] = 1
#     else:
#         dic[z] = dic[z]+1
# print(dic)
# print(sum(list(dic.values())))
# for z in li:
#     if z not in dic:
#         dic[z] = 1
#     else:
#         dic[z] = dic[z]+1
# keys = dic.keys()
# for u in keys:
#     print("{}   {}".format(u,dic[u]))
#     s+= r['label'] + r['comprehensive_cost']
# print(s)
# wei = bs.orders.find({"article_number":{"$in":["CD7069-104"]},"orderGroups":{"$in":[1,3]},"merchantCode":"0004","saleType":"transfer",'pay_time':{"$regex":"11-10"}})
# de = bs.stocks.find({"source":"transfer","batchCode":{"$in":["DE第一批","DE第二批"]}})
# xx = bs.orders.find({"article_number":{"$in":["CD7069-104"]},"orderGroups":{"$in":[1,3]},"merchantCode":"0004","saleType":"transfer"})
# stocks = 0
# li = []
# dic = {}
# for r in dates:
#     xx = bs.stocks.find({"article_number":"10061W","pay_time":{"$regex":"r"},"orderGroups":{"$ne":2}})
#     for o in xx:
#         stocks += o['sku_price']/100
#     print('{}:{}'.format(r,stocks))
#     stocks = 0
#         li.append(o['properties'])
# for z in li:
#     if z not in dic:
#         dic[z] = 1
#     else:
#         dic[z] = dic[z]+1
# keys = dic.keys()
# for u in keys:
#     print("{}   {}".format(u,dic[u]))
#
# s = 0
# xx = bs.orders.find({"merchantCode": "0001", "article_number": {"$in": ["10061W"]}, "orderGroups": {"$in": [1, 3]},"properties":"45.5"})
# for o in xx:
#     s += o['sku_price']/100
# print(s)
#
# for i in de:
#     if 'qty' in i:
#         stocks += i['qty']
# print(stocks)
# li1 = []
# dic = {}
# for i in xx:
#     if 'properties' in i:
#         li1.append(i['properties'])
#
#
# a1 = {'42': 2, '42.5': 2, '40.5': 2, '43': 2, '44.5': 2, '44': 1, '41': 1, '40': 1}
# s = 0
# for i in a1.keys():
#     s += a1[i]
# print(list(a1.keys()),s)